<?php
/**
 * Created by PhpStorm.
 * User: hui
 * Date: 16/8/2
 * Time: 16:43
 */

namespace app\common\validate;

use think\Validate;

class Member extends Validate
{
    protected $rule = [
        'Member|姓名'   => 'require|max:20|regex:[\x7f-\xff]*\w*', //0x7f = 127  0xff = 256 ASCII
        'Age|年龄'      => 'number|between:1,150',
        'Mobile|手机'   => 'require|length:11|regex:^1[34578]{1}\d{9}$',
        'Email|邮箱'    => 'email',
        'QQ'          => 'number|length:5,10',
        'Birthday|生日' => 'require|date',
        'Sex|性别'      => 'in:男,,女',
        'Password'    => 'require|confirm:password_re',
    ];

    protected $message = [
        'Member.require'   => '姓名为必填项',
        'Member.max'       => '姓名的长度不能超过20',
        'Member.regex'     => '姓名中不能含有特殊符号',
        'Age.number'       => '请输入正确的年龄',
        'Mobile.require'   => '手机为必填项',
        'Mobile.length'    => '手机号为11位的数字',
        'Mobile.regex'     => '请输入正确的手机号',
        'Email'            => '请输入正确的邮箱地址',
        'QQ'               => '请输入正确的QQ号码',
        'Birthday.require' => '生日为必选项',
        'Birthday.date'    => '请输入正确的生日',
        'Sex'              => '请选择正确的性别',
        'Password.require' => '请输入新密码',
        'Password.confirm' => '两次输入的密码不一致',
    ];

    protected $scene = [
        'password' => ['Password'],
        'edit'     => ['Age', 'Mobile', 'Email', 'QQ', 'Birthday', 'Sex'],
    ];
}